<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
		<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script type="text/javascript" src="<%=basePath%>Js/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/mycss/bootstrap.min.css" />
</head>

<script type="text/javascript">

function selectConsump_Record(){
	
	var roomNumber = "";
	var vipNumber = "";
	var state = "";
	roomNumber = $("#roomNumber").val();
	vipNumber = $("#vipNumber").val();
	state = $("#state").find("option:selected").text();
	
	window.location.href="selectConsump_Record.do?roomNumber="+roomNumber+"&vipNumber="+vipNumber+"&state="+state;
}

function delivery(serialnum){
	
	$.ajax({
		type:"post",
		url:"delivery.do",
		async: false,
		data:{
			"serialnum":serialnum,
		},
		dataType:"text",
		success:function(result){
			if(result == "1"){
				alert("已选择配送")
			}else{
				alert("选择配送失败")
			}
		},
		error:function(){
			alert("系统故障")
		}
	})
	
}

</script>

<body>
	<hr>
	<h3 align="center">消费记录</h3>
	<hr>
	
	<table>
	<tr>
	<td>房间号：</td>
	<td> <input type="text" class="form-control" id="roomNumber" placeholder="请输入房间号"></td>
	<td>消费账号：</td>
	<td><input type="text" class="form-control" id="vipNumber" placeholder="请输入会员卡号"></td>
	<td>订单状态：</td>
	<td>
	           <select name="state" id="state" class="form-control">

						<option value="">默认</option>

						<option value="">未配送</option>
						
						<option value="">已配送</option>
						
						<option value="">配送中</option>

				</select>
	</td>
	<td>
	<button type="button" class="btn btn-success" onclick="selectConsump_Record()">查询</button>
	</td>
	</tr>
	</table><br>

	<table class="table table-bordered">
		<tr>
			<th>房间号</th>
			<th>商品名称</th>
			<th>商品分类</th>
			<th>单价</th>
			<th>数量</th>
			<th>下单时间</th>
			<th>订单状态</th>
			<th>操作</th>
			<th>消费账号</th>
			<th>备注</th>
		</tr>
		<c:forEach items="${pageInfo.list}" var="conlist">
		<tr>
			<td>${conlist.roomnumber}</td>
			<td>${conlist.product}</td>
			<td>${conlist.classify}</td>
			<td>${conlist.price}</td>
			<td>${conlist.quantity}</td>
			<td>${conlist.reserved2}</td>
				<c:choose>
					<c:when test="${conlist.state == '0'}">
						<td>未配送</td>
					</c:when>
					<c:when test="${conlist.state == '1'}">
						<td>已配送</td>
					</c:when>
					<c:otherwise>
						<td>配送中</td>
					</c:otherwise>
				</c:choose>
				<c:choose>
					<c:when test="${conlist.state == '0'}">
						<td><a href="" onclick="delivery('${conlist.serialnum}')">配送</a></td>
					</c:when>
					<c:when test="${conlist.state == '2'}">
						<td>待客户确认</td>
					</c:when>
					<c:otherwise>
						<td></td>
					</c:otherwise>
				</c:choose>

				<td>${conlist.reserved1}</td>
			<td>${conlist.remark}</td>
		</tr>
		</c:forEach>
	</table>
<c:if test="${inf eq null}">
	<div id="page1">
		<c:if test="${!pageInfo.isFirstPage }">
			<a href="${pageContext.request.contextPath }/queryConsumption_recordAll.do">首页</a>
			<a
				href="${pageContext.request.contextPath }/queryConsumption_recordAll.do?pageNum=${pageInfo.prePage}">上一页</a>
		</c:if>
		<c:if test="${!pageInfo.isLastPage }">
			<a
				href="${pageContext.request.contextPath }/queryConsumption_recordAll.do?pageNum=${pageInfo.nextPage}">下一页</a>
			<a
				href="${pageContext.request.contextPath }/queryConsumption_recordAll.do?pageNum=${pageInfo.lastPage}">末页</a>
		</c:if>
		当前页：${pageInfo.pageNum }/${pageInfo.pages }.
	</div>
</c:if>

<c:if test="${!(inf eq null)}">
	<div id="page1">
		<c:if test="${!pageInfo.isFirstPage }">
			<a href="${pageContext.request.contextPath }/selectConsump_Record.do?roomNumber=${roomNumber}&vipNumber=${vipNumber}&state=${state}">首页</a>
			<a
				href="${pageContext.request.contextPath }/selectConsump_Record.do?pageNum=${pageInfo.prePage}&roomNumber=${roomNumber}&vipNumber=${vipNumber}&state=${state}">上一页</a>
		</c:if>
		<c:if test="${!pageInfo.isLastPage }">
			<a
				href="${pageContext.request.contextPath }/selectConsump_Record.do?pageNum=${pageInfo.nextPage}&roomNumber=${roomNumber}&vipNumber=${vipNumber}&state=${state}">下一页</a>
			<a
				href="${pageContext.request.contextPath }/selectConsump_Record.do?pageNum=${pageInfo.lastPage}&roomNumber=${roomNumber}&vipNumber=${vipNumber}&state=${state}">末页</a>
		</c:if>
		当前页：${pageInfo.pageNum }/${pageInfo.pages }.
	</div>
</c:if>

</body>
</html>